/*
 * Copyright 2009 Lukasz Wozniak
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 *
 * http://www.apache.org/licenses/LICENSE-2.0 
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */
package pl.sind.blip.entities;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Represents tag subscription.
 * 
 * @author Lukasz Wozniak
 *
 */
public class TagSubscription extends Entity{
	private String userPath;
	private String tagPath;
	private Boolean negative;

	public TagSubscription() {
		super();
	}

	public TagSubscription(String userPath, String tagPath, Boolean negative) {
		super();
		this.userPath = userPath;
		this.tagPath = tagPath;
		this.negative = negative;
	}
	
	public TagSubscription(JSONObject jsonObject) throws JSONException {
		userPath = jsonObject.optString("user_path");
		tagPath = jsonObject.optString("tag_path");
		negative = jsonObject.optBoolean("negative");
		
	}

	public String getUserPath() {
		return userPath;
	}

	public void setUserPath(String userPath) {
		this.userPath = userPath;
	}

	public String getTagPath() {
		return tagPath;
	}

	public void setTagPath(String tagPath) {
		this.tagPath = tagPath;
	}

	public Boolean getNegative() {
		return negative;
	}

	public void setNegative(Boolean negative) {
		this.negative = negative;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((negative == null) ? 0 : negative.hashCode());
		result = prime * result + ((tagPath == null) ? 0 : tagPath.hashCode());
		result = prime * result
				+ ((userPath == null) ? 0 : userPath.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TagSubscription other = (TagSubscription) obj;
		if (negative == null) {
			if (other.negative != null)
				return false;
		} else if (!negative.equals(other.negative))
			return false;
		if (tagPath == null) {
			if (other.tagPath != null)
				return false;
		} else if (!tagPath.equals(other.tagPath))
			return false;
		if (userPath == null) {
			if (other.userPath != null)
				return false;
		} else if (!userPath.equals(other.userPath))
			return false;
		return true;
	}

	@Override
	public String toString() {
		StringBuilder b = new StringBuilder();
		b.append(TagSubscription.class.getName()).append("{");
		b.append("userPath: ").append(userPath);
		b.append(", tagPath: ").append(tagPath);
		b.append(", negative: ").append(negative);
		b.append("}");
		return b.toString();
	}
	
	
	
	
}
